<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'cafe-owner-subscribe-form',
	'enableAjaxValidation'=>true,
	'clientOptions' => array('validateOnSubmit' => true,
   							 'validateOnChange' => false)
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'shopId'); ?>
		<?php if ($model->isNewRecord):?>
			<?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
				     'name'=>'cafeName',
				     'sourceUrl'=>array('coffeeShop/ajaxQuickSearchHasOwner'),
				     'options'=>array(
				     	'showAnim'=>'fold',
	              		'minLength'=>2,
	              		'select'=>'js:function(event,ui){$("#CafeOwnerSubscribe_shopId").val(ui.item.id);}',
				      ),
				   ));
			?>
			<?php echo $form->hiddenField($model,'shopId'); ?>
			<?php echo $form->error($model,'shopId'); ?>
		<?php else:?>
			<?php echo $model->shop->name;?>
		<?php endif;?>
	</div>
<?php /*
	<div class="row">
		<?php echo $form->labelEx($model,'txn_id'); ?>
		<?php echo $form->textField($model,'txn_id',array('size'=>60,'maxlength'=>64)); ?>
		<?php echo $form->error($model,'txn_id'); ?>
	</div>
*/?>

	<div class="row">
		<?php echo $form->labelEx($model,'startDate'); ?>
		<?php if ($model->isNewRecord):?>
			<?php echo $form->hiddenField($model,'startDate'); ?>
			<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
				    'name'=>'startDateSelect',
				    'options'=>array(
						'altField'=>'#'.CHtml::activeId($model, "startDate"),
						'onSelect'=>'js:function(){
							$("#CafeOwnerSubscribe_startDate").val($("#CafeOwnerSubscribe_startDate").val()/1000);
						}'			
				    ),	   
				));
			?>
			<?php echo $form->error($model,'startDate'); ?>
		<?php else:?>
			<?php echo date('d/m/Y',$model->startDate);?>
		<?php endif;?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'endDate'); ?>
		<?php echo $form->hiddenField($model,'endDate'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
			    'name'=>'endDateSelect',
			    'options'=>array(
					'altField'=>'#'.CHtml::activeId($model, "endDate"),
					'onSelect'=>'js:function(){
						$("#CafeOwnerSubscribe_endDate").val($("#CafeOwnerSubscribe_endDate").val()/1000);
					}'
			    ),
		    	'value'=>$model->endDate?date('d/m/Y',$model->endDate):'',
			));
		?> 
		<?php echo $form->error($model,'endDate'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->